package edu.cuit.avatar.generic;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 几何图形通用的父类
 * 抽象类不能创建其实例
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/10 8:49
 */
public abstract class Geometric {
    private String color = "white";

    private boolean filled;

    private LocalDateTime createdTime = LocalDateTime.now();

    public Geometric(){

    }

    public Geometric(String color, boolean filled){
        this.color = color;
        this.filled = filled;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public boolean isFilled() {
        return filled;
    }

    public void setFilled(boolean filled) {
        this.filled = filled;
    }

    public LocalDateTime getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(LocalDateTime createdTime) {
        this.createdTime = createdTime;
    }

    @Override
    public final String toString() {
        return String.format("created on %s, color:%s, filled:%s, area: %.2f, perimeter: %.2f",
                DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(createdTime),
                color, filled, getArea(), getPerimeter());
    }


    /**
     * 所有子类通用的行为：该行为不知道如何描述====>抽象的
     * 抽象方法:只有方法的声明而没有实现，由具体的子类进行实现
     * 包含抽象方法的类必须是抽象类
     */
    public abstract float getArea();

    /**
     * 计算周长
     * @return 周长
     */
    public abstract float getPerimeter();
}
